<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/jsp/comm_css_include.jsp"%>
<!doctype html>
<html>
<head>
</head>
<body class="gray-bg">

<input type="hidden" value="${busiId }" id="busiId" name="busiId"/>
<input type="hidden" value="${cusId }" id="customerId" name="customerId"/>
<input type="hidden" id="id" name="id"/>
<div class="container creditbody">
	<div class="iboxtitle">
		<span><i class="glyphicon glyphicon-map-marker"></i>&nbsp;贷后业务>客户申请代偿</span>
    </div>
    <div class="buttonfixed">
    	<button type="button" class="btn dpbtn_blue" onclick="save();" id="saveStu" style="display: none;">保存提交</button>
	    <button type="button" class="btn dpbtn_red" onclick="reBack();" id="reBackStu"  style="display: none;" >撤回</button>
	</div>    
	         <div class="ibox-content ibox-con">
				<form class="form-horizontal" id="">
				<%@include file="/jsp/comm_yw_info_include.jsp"%>
				<%@include file="/jsp/comm_yw_daidian_include_notime.jsp"%>
				<div class="business-padding" style="padding:0">
					<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table" style="margin-bottom: 0;">
						 <tr>
							<td align="right">
								<label class="control-label np">代偿日期：</label>
							</td>
							<td>
								<input id="dateInsteadB" name="" placeholder="代偿日期" class="laydate-icon form-control" onclick="laydate()" />
							</td>
						</tr>	
					</table>	
					<table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">	
						<tr>
							<td align="right" valign="top">
								<label class="control-label np">信息备注：</label>
							</td>
							<td>
								<textarea id="remarks" rows="" cols="100" class="form-control"></textarea>
							</td>
						</tr>
					</table>
				</div>
				<div class="business-manwife">代偿附件</div>
				<div class="business-padding">
					<div class="zx-addimg">
					<ul id="ZHONG_YAO_YUAN_JIAN">
						<li><img
							filelabel="${attachmentLabelNames.DAI_CHANG_FU_JIAN1 }"
							src="${basePath}/img/shangchuanzhaopian.png" width="110px"
							height="110px"
							class="zx-imgPre ${attachmentLabelNames.DAI_CHANG_FU_JIAN1 }">
							<span
							filelabelDelSpan="${attachmentLabelNames.DAI_CHANG_FU_JIAN1 }"
							class="hidden bt-cancle glyphicon glyphicon-trash"
							onclick="deleleFileRecord(this,'${attachmentLabelNameValues.DAI_CHANG_FU_JIAN1 }',false);"></span>
							<div class="img-layer">
								<div></div>
								<span
									filelabelLabelSpan="${attachmentLabelNames.DAI_CHANG_FU_JIAN1 }">${attachmentLabelNameValues.DAI_CHANG_FU_JIAN1 }</span>
							</div>
							<div filelabelDiv="${attachmentLabelNames.DAI_CHANG_FU_JIAN1 }"
								class="hidden button-des">
								<a type="button"
								class="abuttonStylele"  filelabelADown="${attachmentLabelNames.DAI_CHANG_FU_JIAN1 }"
									download="shangchuanzhaopian.png"
									href="${basePath}/img/shangchuanzhaopian.png">下载</a> <a
									type="button" class="abuttonStyleri"  onclick="showImg(this);">详情</a>
							</div> <a href="javascript:void(0);" class="file"> <span>上传资料</span>
								<input type="file"
								accept="image/gif,image/jpeg,image/bmp,image/png,image/jpg"
								onchange="uploadFile(this,'${modeIDTypeNames.CWDK }','ZHONG_YAO_YUAN_JIAN', false, false);" />
						</a></li>
						<li><img
							filelabel="${attachmentLabelNames.DAI_CHANG_FU_JIAN2 }"
							src="${basePath}/img/shangchuanzhaopian.png" width="110px"
							height="110px"
							class="zx-imgPre ${attachmentLabelNames.DAI_CHANG_FU_JIAN2 }">
							<span
							filelabelDelSpan="${attachmentLabelNames.DAI_CHANG_FU_JIAN2 }"
							class="hidden bt-cancle glyphicon glyphicon-trash"
							onclick="deleleFileRecord(this,'${attachmentLabelNameValues.DAI_CHANG_FU_JIAN2 }',false);"></span>
							<div class="img-layer">
								<div></div>
								<span
									filelabelLabelSpan="${attachmentLabelNames.DAI_CHANG_FU_JIAN2 }">${attachmentLabelNameValues.DAI_CHANG_FU_JIAN2 }</span>
							</div>
							<div filelabelDiv="${attachmentLabelNames.DAI_CHANG_FU_JIAN2 }"
								class="hidden button-des">
								<a type="button"
								class="abuttonStylele"  filelabelADown="${attachmentLabelNames.DAI_CHANG_FU_JIAN1 }"
									download="shangchuanzhaopian.png"
									href="${basePath}/img/shangchuanzhaopian.png">下载</a> <a
									type="button" class="abuttonStyleri"  onclick="showImg(this);">详情</a>
							</div> <a href="javascript:void(0);" class="file"> <span>上传资料</span>
								<input type="file"
								accept="image/gif,image/jpeg,image/bmp,image/png,image/jpg"
								onchange="uploadFile(this,'${modeIDTypeNames.CWDK }','ZHONG_YAO_YUAN_JIAN', false, false);" />
						</a></li>
					</ul>	
				</div>	
	            </div>
				<div class="business-manwife">经办信息</div>
				<div class="padding-nono">
				    <table cellpadding="0" cellspacing="0" border="0" class="buyinfor-table">
						 <tr>
							<td align="right">
								<label class="control-label np">经办人：</label>
							</td>
							<td> 
								<input class="form-control" type="text" id="operater" name="" readonly="readonly" value="${current_user_key.uname}" />
							</td>	
							<td align="right">
								<label class="control-label np">经办时间：</label>
							</td>
							<td>
								<input id="operaterTime" readonly="readonly" name="" placeholder="经办时间" class="laydate-icon form-control"  />
							</td>
						</tr>	
					</table>
					
				</div>			
			</form>
	 	</div>
 	</div>
</div>	
	
 	<!-- layerDate plugin javascript -->
    <script type="text/javascript" src="${basePath}/js/plugins/layer/laydate/laydate.js"></script>
    
	<!-- public quote -->
    <%@include file="/jsp/comm_js_include.jsp"%>
    
    <!-- 文件上传 -->
	<%@include file="/jsp/common_fileupload_include.jsp"%>
	
    <script type="text/javascript">
	    jQuery(function($) {  
	    	getData();
	    });
	    
	    var getData=function(){
	    	$.dpAjax({
	    		show:false,
	    		data:{"busiId":$.getUrlData("busiId")},
	    		url:'${basePath}/DhInsteadPaymentApplyController/list',
				success: function(datas){
					var result = datas.result.rows[0];
					if(result && result != ""){
						var statusInstead = result.statusInstead;
						if(statusInstead == "10" || statusInstead == "15" || statusInstead == "20"){
			    			$("#saveStu").show();
				    	}
				    	if(statusInstead == "20" || statusInstead == "25"){
				    		$("#reBackStu").show();
				    	} 
				    	$("#id").val(result.replaceId);
				    	$("#dateInsteadB").val(formateToDate(result.dateInstead));
				    	$("#remarks").val(result.remarks);
				    	$("#operaterTime").val(formateIntegerMinutes(result.modified));
				    	showAttentment($.getUrlData('busiId'), null, '${modeIDTypeNames.CWDK }');
					}else{
						$("#operaterTime").val(laydate.now());
						$("#saveStu").show();
					}
			    	
	            }
	    	});
	    }
	    
	    var reBack=function(){
	    	$.dpAjax({
	    		data:{"id":$.getUrlData("busiId")},
	    		url:'${basePath}/DhInsteadPaymentApplyController/revokeInsteadPayment',
				success: function(datas){
					if(datas.result){
						layer.msg('撤回成功！', {icon: 6});
						setTimeout(function () {
		 		 			window.location.href = "${basePath}/web/system/loanAfter/kehusqDaiChangList.jsp";
		 		 		}, 1000);
					}
	            }
	    	});
	    } 
	    
	    var save=function(){
	    	var data={};
	    	data.dateInstead=$("#dateInsteadB").val();
	    	data.remarks=$("#remarks").val();
	    	data.busiId= $("#busiId").val();
	    	data.cusId= $.getUrlData("cusId");
	    	data.insteadId=$.getUrlData("applyId");
	    	data.statusInstead=20;
	    	var id=$("#id").val();
	    	if(id && id !=""){
	    		url='${basePath}/DhInsteadPaymentApplyController/modify';
	    		data.id=id;
	    	}else{
	    		url='${basePath}/DhInsteadPaymentApplyController/save';
	    	}
	    	$.dpAjax({
	    		url:url,
	    		data:data,
				success: function(datas){
					layer.msg('执行成功！', {icon: 6});
					setTimeout(function () {
	 		 			window.location.href = "${basePath}/web/system/loanAfter/kehusqDaiChangList.jsp";
	 		 		  }, 1000);
					return;
	            }
	    	});
	    }
	    
    </script>
</body>
</html>
